import os

from flask import current_app, jsonify, request
from utils.douBaoAI import douBaoAI
from utils.douBaoAI import system_prompt

async def query():
    try:
        data = request.json
        messages = data.get('messages', None)
        system_message = system_prompt
        user_message = data.get('user_message', None)
        stream = data.get('stream', None)
        result = await douBaoAI.query(messages, system_message, user_message, stream)
        return result
    except Exception as e:
        print(e)
        return "Error"

